@model CheckoutAttributeSearchModel

@{
    //page title
    ViewBag.PageTitle = T("Admin.Catalog.Attributes.CheckoutAttributes").Text;
    //active menu item (system name)
    Html.SetActiveMenuItemSystemName("Checkout attributes");
}

<div class="content-header clearfix">
    <h1 class="pull-left">
        @T("Admin.Catalog.Attributes.CheckoutAttributes")
    </h1>
    <div class="pull-right">
        <a asp-action="Create" class="btn bg-blue">
            <i class="fa fa-plus-square"></i>
            @T("Admin.Common.AddNew")
        </a>
        @await Component.InvokeAsync("AdminWidget", new { widgetZone = AdminWidgetZones.CheckoutAttributeListButtons })
        <button type="button" id="delete-selected" class="btn bg-red">
            <i class="fa fa-trash-o"></i>
            @T("Admin.Common.Delete.Selected")
        </button>
        <nop-action-confirmation asp-button-id="delete-selected" />
    </div>
</div>

<div class="content">
    <div class="panel-group">
        <div class="panel panel-default">
            <div class="panel-body">
                <p>
                    @T("Admin.Catalog.Attributes.CheckoutAttributes.Description")
                </p>
                @await Html.PartialAsync("Table", new DataTablesModel
                {
                    Name = "checkoutattributes-grid",
                    UrlRead = new DataUrl("List", "CheckoutAttribute", null),
                    Length = Model.PageSize,
                    LengthMenu = Model.AvailablePageSizes,
                    ColumnCollection = new List<ColumnProperty>
                    {
                        new ColumnProperty(nameof(ProductAttributeModel.Id))
                        {
                            IsMasterCheckBox = true,
                            Render = new RenderCheckBox("checkbox_checkoutattributes"),
                            ClassName =  NopColumnClassDefaults.CenterAll,
                            Width = "50"
                        },
                        new ColumnProperty(nameof(CheckoutAttributeModel.Name))
                        {
                            Title = T("Admin.Catalog.Attributes.CheckoutAttributes.Fields.Name").Text
                        },
                        new ColumnProperty(nameof(CheckoutAttributeModel.AttributeControlTypeName))
                        {
                            Title = T("Admin.Catalog.Attributes.CheckoutAttributes.Fields.AttributeControlType").Text,
                            Width = "200"
                        },
                        new ColumnProperty(nameof(CheckoutAttributeModel.IsRequired))
                        {
                            Title = T("Admin.Catalog.Attributes.CheckoutAttributes.Fields.IsRequired").Text,
                            Width = "100",
                            ClassName = NopColumnClassDefaults.CenterAll,
                            Render = new RenderBoolean()
                        },
                        new ColumnProperty(nameof(CheckoutAttributeModel.DisplayOrder))
                        {
                            Title = T("Admin.Catalog.Attributes.CheckoutAttributes.Fields.DisplayOrder").Text,
                            Width = "100",
                            ClassName = NopColumnClassDefaults.CenterAll
                        },
                        new ColumnProperty(nameof(CheckoutAttributeModel.Id))
                        {
                            Title = T("Admin.Common.Edit").Text,
                            Width = "100",
                            ClassName = NopColumnClassDefaults.Button,
                            Render = new RenderButtonEdit(new DataUrl("Edit"))
                        }
                    }
                })

                <script>
                    $(document).ready(function () {
                        $('#delete-selected-action-confirmation-submit-button').bind('click', function () {
                            var postData = {
                                selectedIds: selectedIds
                            };
                            addAntiForgeryToken(postData);
                            $.ajax({
                                cache: false,
                                type: "POST",
                                url: "@(Url.Action("DeleteSelected", "CheckoutAttribute"))",
                                data: postData,
                                error: function (jqXHR, textStatus, errorThrown) {
                                    $('#deleteSelectedFailed-info').text(errorThrown);
                                    $('#deleteSelectedFailed').click();
                                },
                                complete: function (jqXHR, textStatus) {
                                    updateTable('#checkoutattributes-grid');
                                }
                            });
                            $('#delete-selected-action-confirmation').modal('toggle');
                            return false;
                        });
                    });
                </script>
                <nop-alert asp-alert-id="deleteSelectedFailed" />
            </div>
        </div>
    </div>
</div>